<?php
namespace {$service.namespace};

use app\model\{$tables[0].model_name} as {$tables[0].model_name}Model;

class {$service.class_name}
{
    protected $model;

    public function __construct()
    {
        $this->model = new {$tables[0].model_name}Model();
    }

    //查询分页数据
    public function getPageList($page, $limit, $where = [])
    {
        return $this->model->where($where)
            ->order("id desc")
            ->paginate(['page' => $page, 'list_rows' => $limit])
            ->toArray();
    }

    //根据id查询明细
    public function getInfoById($id){
        return $this->model->where('id',$id)->find();
    }

    //新增
    public function add($params){
        return $this->model->createInfo($params);
    }

    //编辑
    public function update($params){
        return $this->model->updateInfo($params['id'],$params);
    }

    //删除
    public function delete($id){
        $info = $this->model->find($id);
        $res = $info->delete();
        if ($res){
            return true;
        }
        return false;
    }
}